package com.firstcloud.controller;

import com.firstcloud.pojo.CommonResult;
import com.firstcloud.pojo.MallTest;
import com.firstcloud.service.MallTestService;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/*
 *@author HuJun
 */
@RestController
public class PaymentController {
    @Value("${server.port}")
    private String serverPort;
    @Resource
    private MallTestService mallTestService;

    @GetMapping("/payment/get/{id}")
    public CommonResult getPaymentById(@PathVariable("id") Integer id){
        //使用IService接口自带的方法
        MallTest result = mallTestService.getById(id);

        if (result !=null) {
            return new CommonResult(200, "插入数据库成功" + ":" + serverPort, result);
        } else {
            return new CommonResult(400, "插入数据库失败", null);
        }
    }

}
